app.get("/", (req, res) => {
  res.send("hello get");
});

app.post("/", (req, res) => {
  res.send("hello post");
});

// 获取 params 参数
// http://127.0.0.1:3000/test/66
app.get("/test/:id", (req, res) => {
  const { id } = req.params;
  console.log(req.query, req.params, req.body);
  res.send(`id: ${id}`);
});

// 获取 query 参数
// http://127.0.0.1:3000/test?id=88&name=peak
app.get("/test", (req, res) => {
  const { id, name } = req.query;
  res.send(`id: ${id}, name: ${name}`);
});

// 获取body参数
app.post("/test", (req, res) => {
  const testData = req.body;
  console.log(testData);
  res.send(`testData${JSON.stringify(testData)}`);
});
